package com.ninth;


import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class AOPTest {

    @Test
    public void test() throws FileNotFoundException {
        //1、读取配置文件
        InputStream in = new FileInputStream("/Users/jacksonmike/IdeaProjects/Stage11/src/main/resources/bean.properties");
        // InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("bean.properties");
        //2、创建内省的BeanFactory的工厂对象
        BeanFactory beanfactory = new BeanFactory(in);

        //3、获取代理对象
        //这一步：创建了ProxyFactoryBean的完整对象，同时也对ProxyFactoryBean类的两个属性private Object target;和private Advice advice;进行了set方法的设置属性值
        ProxyFactoryBean proxyfactorybean = (ProxyFactoryBean) beanfactory.getBean("bean");

        //4、继而获取目标类的代理对象
        IManager proxy = (IManager) proxyfactorybean.getProxy();
        proxy.add("God bless the US");
    }
}